<template>
<div style="display: flex;">
  <div style="box-shadow: 2px 0 6px rgb(0 21 41); width: auto">
    <el-menu
        style="min-height: calc( 100vh - 50px );height: 100%"
        background-color="rgb(48,65,86)"
        text-color="#fff"
        :default-active="path"
        :collapse="isCollapse"
        router
        collapse-transition
    >
      <el-sub-menu index="1">
        <template #title>
          <el-icon><Menu /></el-icon>
          <span>系统管理</span>
        </template>
        <el-menu-item index="/home" ><i><el-icon><Setting /></el-icon></i>首页</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="2" v-if="user.role === '管理员' " >
        <template #title>
          <el-icon><UserFilled /></el-icon>
          <span>用户管理</span>
        </template>
        <el-menu-item index="/user" ><i><el-icon><User /></el-icon></i>用户信息</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="3">
        <template #title>
          <el-icon><User /></el-icon>
          <span>比赛管理</span>
        </template>
        <el-menu-item index="/game" ><i><el-icon><User /></el-icon></i>比赛信息</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="4" v-if="user.role === '主持人' || user.role === '管理员' " >
        <template #title>
          <el-icon><User /></el-icon>
          <span>规则管理</span>
        </template>
        <el-menu-item index="/rules" ><i><el-icon><User /></el-icon></i>规则信息</el-menu-item>
      </el-sub-menu>
      <div style="text-align: right;color: white;">
        <el-icon size="20px"  v-show="isCollapse" @click="collapse"><DArrowRight/></el-icon>
        <el-icon size="20px" v-show="!isCollapse" @click="collapse"><DArrowLeft /></el-icon>
      </div>
    </el-menu>
<!--  </el-aside>-->

</div>
</div>
</template>

<script>

export default {
  name: "Aside",
  setup(){
    return{
    }
  },
  data(){
    return{
      isCollapse:false,
      path:"",
      sideWidth:200,
      user:{}
    }
 },
  created() {
    this.user=JSON.parse(localStorage.getItem("user"))
    // console.log(this.user.role)
  },
  methods:{
    collapse(){
      this.isCollapse=!this.isCollapse;
      if(this.isCollapse){
        this.sideWidth=60
      }else{
        this.sideWidth=200
      }
    }
  }
}
</script>

<style scoped>

</style>